var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : '127.0.0.1',
  user     : 'root',
  password : 'root',
  database : 'student'
});
connection.connect();
let page=1;
let pageSize=2;
console.log(new Date().toLocaleString().replace("/","-").replace("/","-"));
let sql = "select * from student limit " + (page - 1) * pageSize + "," + pageSize;
connection.query(sql, (err, data) => {
 
  console.log(data);
 
});
connection.query('SELECT count(*) from student', function (error, results, fields) {
  if (error) throw error;
  console.log("查询结果学生总数是");
  console.log(results);
});
connection.query('select count(*) from student where stu_six="男"',function (error, results) {
  if (error) throw error;
  console.log("查询结果是男的");
  console.log(results);
});
connection.query('select count(*) from student where stu_six="女"',function (error, results) {
  if (error) throw error;
  console.log("查询结果是女的");
  console.log(results);
});
connection.query('select count(*) from student where stu_age<18',function (error, results) {
  if (error) throw error;
  console.log("查询结果小于18是");
  console.log(results);
});
connection.query('select count(*) from student where stu_age>=18 and stu_age<45',function (error, results) {
  if (error) throw error;
  console.log("查询结果大于等于18，小于45是");
  console.log(results);
});
connection.query('select count(*) from student where stu_age<45',function (error, results) {
  if (error) throw error;
  console.log("查询结果大于45是");
  console.log(results);
});

connection.end();